//
//  DateDetailViewController.swift
//  ShouChong
//
//  Created by 陈友文 on 2024/7/17.
//

import UIKit
import SwiftUI
import StoreKit

class DateDetailViewController: BaseViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
    }
    
    private func setupUI() {
        self.title = "历史记录"
        let hostVC = UIHostingController(rootView: DataDetailView())
        hostVC.view.backgroundColor = UIColor(named: "color_bg")
        hostVC.view.frame = kScreenBounds
        self.view.addSubview(hostVC.view)
        let label = UILabel()
        label.text = "列表"
        label.textColor = UIColor(named: "color_text_black")
        label.isUserInteractionEnabled = true
        label.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(pushToHisDetail)))
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: label)
        DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
            SKStoreReviewController.requestReview()
        }
    }

    @objc func pushToHisDetail() {
        let generator = UIImpactFeedbackGenerator(style: .light)
        generator.prepare()
        generator.impactOccurred()
        let vc = HisDetailViewController()
        self.navigationController?.pushViewController(vc, animated: true)
    }

}
